SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspNews_SEARCH
(
@newsId int = null,
@title nvarchar(150) = null,
@content nvarchar(MAX) = null,
@isDeleted bit = null,
@isVisible bit = null,
@createDate datetime = null,
@lastModifiedDate datetime = null
)
AS

SELECT
  *
FROM
  [dbo].[News]
WHERE
  (@newsId IS NULL OR [NewsId] = @newsId)
AND
  (@title IS NULL OR @title = '' OR [Title] LIKE @title + '%')
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)
AND
  (@isVisible IS NULL OR [IsVisible] = @isVisible)
AND
  (@createDate IS NULL OR [CreateDate] = @createDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)

GO
